import 'package:flutter/material.dart';
import 'package:yp/config/index.dart';
import 'package:yp/widgets/dashed_line.dart';
import 'package:yp/widgets/index.dart';

class LuckyDrawList extends StatefulWidget {
  const LuckyDrawList({Key key}) : super(key: key);

  @override
  _LuckyDrawListState createState() => _LuckyDrawListState();
}

class _LuckyDrawListState extends State<LuckyDrawList>
    with SingleTickerProviderStateMixin {
  AnimationController _controller;

  @override
  void initState() {
    super.initState();
    _controller = AnimationController(vsync: this);
  }

  @override
  void dispose() {
    super.dispose();
    _controller.dispose();
  }

  @override
  Widget build(BuildContext context) {
    return CustomScrollView(slivers: [
      SliverToBoxAdapter(
          child: Column(
        children: [
          Row(
            children: [
              Expanded(
                flex: 2,
                child: Padding(
                  padding: const EdgeInsets.only(top: 10, bottom: 14),
                  child: Center(
                    child: Text('姓名',
                        style: TextStyle(
                            color: EsColors.Title,
                            fontSize: EsSizes.SM,
                            fontWeight: EsFontWeights.Medium)),
                  ),
                ),
              ),
              Expanded(
                flex: 3,
                child: Padding(
                  padding: const EdgeInsets.only(left: 30),
                  child: Text('抽奖码',
                      style: TextStyle(
                          color: EsColors.Title,
                          fontSize: EsSizes.SM,
                          fontWeight: EsFontWeights.Medium)),
                ),
              )
            ],
          ),
          YpLine(indent: 12),
          ListView.separated(
              shrinkWrap: true,
              physics: NeverScrollableScrollPhysics(),
              padding: EdgeInsets.zero,
              itemBuilder: (context, index) => _item(index),
              separatorBuilder: (context, index) => Padding(
                    padding: const EdgeInsets.only(left: 12),
                    child: DashLine(
                        color: Color(0xffd8d8d8), height: 1, dashWidth: 6),
                  ),
              itemCount: 10),
          YpLine(indent: 12),
          SizedBox(height: 14),
          Center(
              child: Text('到底了~',
                  style: TextStyle(
                      color: EsColors.ContentSecondary,
                      fontSize: EsSizes.XXS,
                      fontWeight: EsFontWeights.Normal)))
        ],
      ))
    ]);
  }

  Widget _item(int index) {
    return Padding(
      padding: const EdgeInsets.only(top: 10, bottom: 12),
      child: Row(
        children: [
          Expanded(
            flex: 2,
            child: Center(
              child: Text('张三',
                  style: TextStyle(
                      color: EsColors.TitleSecondary,
                      fontSize: EsSizes.SM,
                      fontWeight: EsFontWeights.Normal)),
            ),
          ),
          Expanded(
            flex: 3,
            child: Text('asdfghjklqwweerr',
                style: TextStyle(
                    color: EsColors.TitleSecondary,
                    fontSize: EsSizes.SM,
                    fontWeight: EsFontWeights.Normal)),
          )
        ],
      ),
    );
  }
}
